#ifndef WIDGET_H
#define WIDGET_H
#include<QUdpSocket>
#include <QWidget>

QT_BEGIN_NAMESPACE
namespace Ui { class Widget; }
QT_END_NAMESPACE

class Widget : public QWidget
{
    Q_OBJECT

public:
    Widget(QWidget *parent ,QString myname);

    enum Msgtype{Msg,UserEnter,UserLeft};//枚举
    void sndMsg(Msgtype type);//广播dp信息
    QString getname();
    QString getMsg();
    void userEnter(QString username);
    void userleft(QString username,QString time);
    void receivemassage();//接受dp信息
    //重写关闭事件
    void closeEvent(QCloseEvent *);


    ~Widget();
signals:
   void closeWidget();
private:
    Ui::Widget *ui;
    QString myname;
    quint16 port;//端口
    QUdpSocket *udpsocket;//套接字
};
#endif // WIDGET_H
